package com.study.studyelasticsearch.util.es.extractor.vo;

import java.util.ArrayList;
import java.util.List;

/**
 * 聚合桶
 * @author 吴宇亮 on 2022/5/30 17:30
 */
public class BucketVo {

    private List<AbstractBucketItemVo> bucketItemList = new ArrayList<>();

    public BucketVo addBucketItem(AbstractBucketItemVo bucketItem) {
        this.bucketItemList.add(bucketItem);
        return this;
    }

    public AbstractBucketItemVo getBucketItem(String key){
        for (AbstractBucketItemVo abstractBucketItemVo : bucketItemList) {
            if(key.equals(abstractBucketItemVo.getKey())){
                return abstractBucketItemVo;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "BucketVo{" +
                "bucketItemList=" + bucketItemList +
                '}';
    }
}
